import sympy

x = sympy.Symbol('x')
a, b = 0, 1
f = x

integral_result = sympy.integrate(f, (x, a, b))
average_value = integral_result / (b - a)

# 解方程 f(x) = average_value 来找到ξ
xi = sympy.solve(f - average_value, x)

xi_value = xi[0]

print(f"∫_[{a},{b}] {f} dx = {integral_result}")
print(f"平均值: {average_value}")
print(f"ξ = {xi_value}, f(ξ) = {f.subs(x, xi_value)}")
print(f"验证: f(ξ)(b-a) = {f.subs(x, xi_value) * (b-a)}")